import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  server: {
    port: 8444,
    host: true,
    open: true,
    proxy: {
      "/api": {
        target: "http://120.55.183.212:5059",
        // target: "http://localhost:5059",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
      "/hello2": {
        
        target: "http://120.55.183.212:5059",
        // target: "http://localhost:5059",

        changeOrigin: true,
        rewrite: (path) => path,
      },
      "/room/sse": {
        target: "http://120.55.183.212:5050/sseapi",
        changeOrigin: true,
        rewrite: (path) => path,
      },
    },
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks: {
          // 将 lodash 拆分成单独的 chunk
          lodash: ["lodash"],
          // 将 vue 相关的库拆分成单独的 chunk
          vue: ["vue", "vue-router"],
        },
      },
    },
  },
});
